<?php 
	header("Content-type: text/html; charset=utf-8");
	require_once('auth_i.inc.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=8" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/themes/redmond/jquery-ui-1.8.9.custom.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/ui.multiselect.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/asud.css" />

	<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
	<script src="js/i18n/grid.locale-ru.js" type="text/javascript"></script>
	<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
	<script src="js/jquery-ui-1.8.9.custom.min.js" type="text/javascript"></script>

<script type="text/javascript">

$(function() { 
  $("#list").jqGrid({
    url:'req/grp_list.php',
	editurl:'req/grp_edit.php',	
    datatype: 'json',
    mtype: 'GET',
    colNames:['Название', 'Описание'],
    colModel :[ 
      {name:'name', index:'name', width:185, editable: true, editoptions:{size:20}}, 
      {name:'g_desc', index:'g_desc', width:200, editable: true, edittype:"textarea", editoptions:{rows:"2",cols:"20"}}, 
    ],
    sortname: 'name',
    sortorder: 'desc',
    viewrecords: true,
  });

$( "#edit-button" )
			.button()
			.click(function() {
				var gr = jQuery("#list").jqGrid('getGridParam','selrow'); 

				if( gr != null ) 
					jQuery("#list").jqGrid('editGridRow',gr,{height:150,reloadAfterSubmit:false,closeAfterEdit:true}); 
				else 
					alert("Выбирите строку для редактирования !"); 
			});

$( "#add-button" )
			.button()
			.click(function() {
				jQuery("#list").jqGrid('editGridRow',"new",{height:150,reloadAfterSubmit:true,closeAfterAdd:true}); 
			});


$("#remove-button")
			.button()
			.click(function() { 

				var gr = $("#list").jqGrid('getGridParam','selrow'); 
				if( gr != null ) 
				{
					$("#list").jqGrid('delGridRow',gr,{reloadAfterSubmit:true}); 
				}
				else 
				{
					alert("Выбирите строку для удаления !"); 
				}
			});
		
}); 

</script>

</head>
<body>
<?php // menu bar
	require_once('menu.inc.php');

	print menu($menu_items, 'group.php');
?>

<div id="main-box">
	<table id="list"></table> 
	<div id="button-box">	
		<button id="add-button">Добавить</button>
		<button id="edit-button">Редактировать</button>
		<button id="remove-button">Удалить</button>
	</div>
</div>

</body>
</html>
